﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace EbbinghausWord.BLL
{
    /// <summary>
    /// 单词备份管理类
    /// </summary>
    public class BackupManager
    {
        /// <summary>
        /// 备份单词表
        /// </summary>
        public static void BackupWorkbook()
        {
            WordBookManager.WordBook.SaveUserWordBookFile(SystemConfig.BackupFileName);
        }

        /// <summary>
        /// 恢复单词本
        /// </summary>
        public static void ResotreWorkbook()
        {
            WordBookManager.WordBook = StoreManager.OpenFile(SystemConfig.BackupFileName);
            StoreManager.SaveUserWordbook();
            WordBookManager.IsNeedReflesh = true;
        }

        /// <summary>
        /// 是否有备份文件
        /// </summary>
        /// <returns></returns>
        public static bool IsExistBackup()
        {
            return StoreManager.IsFileExist(SystemConfig.BackupFileName);
        }

        /// <summary>
        /// 获得上次备份时间
        /// </summary>
        /// <returns></returns>
        public static string GetBackupDate()
        {
            if (!IsExistBackup()) return "(无)";
            return StoreManager.GetFileLastWriteTime(SystemConfig.BackupFileName).ToString("yyyy-MM-dd HH:mm:ss");
        }


    }
}
